﻿using System.Web;
using System.Web.Optimization;
using System;

namespace JCTimes.Portal
{
    public class BundleConfig
    {
        // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.IgnoreList.Clear();
            AddDefaultIgnorePatterns(bundles.IgnoreList);

            #region Scripts
            //layout
            bundles.Add(new ScriptBundle("~/bundles/treeviewnew").Include(
                            "~/Scripts/treeview/jquery.treeview.js"));

            //layout
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                            "~/Scripts/jquery-{version}.min.js",
                            "~/Scripts/jquery.unobtrusive-ajax.min.js",
                            "~/Scripts/jquery.form.js",
                            "~/Scripts/common.js"));


            //jquery.form
            bundles.Add(new ScriptBundle("~/bundles/form").Include(
                        "~/Scripts/jquery.form.js"));
            //jquery.tree
            bundles.Add(new ScriptBundle("~/bundles/treeview").Include(
                        "~/Scripts/jquery.tree.js"));

            //jquery cascade
            bundles.Add(new ScriptBundle("~/bundles/cascade").Include(
                                    "~/Scripts/jquery.cascade-select.js"));


            //login
            bundles.Add(new ScriptBundle("~/bundles/login").Include(
                        "~/Scripts/jquery-{version}.min.js",
                        "~/Scripts/login.js"));


            //jqueryui
            bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
                        "~/Scripts/jquery-ui-{version}.min.js"));

            ////jqueryajax
            //bundles.Add(new ScriptBundle("~/bundles/jqueryajax").Include(
            //         "~/Scripts/jquery.unobtrusive-ajax.min.js"));


            //jqueryval
            bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                //"~/Scripts/jquery.unobtrusive-ajax.min.js",
                        "~/Scripts/jquery.validate.min.js",
                        "~/Scripts/jquery.validate.unobtrusive.min.js"));



            // Use the development version of Modernizr to develop with and learn from. Then, when you're
            // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
            bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                        "~/Scripts/modernizr-*"));
            #endregion

            #region Styles
            //treeview
            bundles.Add(new StyleBundle("~/Content/treeview").Include(
                      "~/Scripts/treeview/jquery.treeview.css"));

            //edit-form
            bundles.Add(new StyleBundle("~/Content/forms").Include(
                      "~/Content/forms.css"));

            bundles.Add(new StyleBundle("~/Content/jquerytree").Include(
                      "~/Content/jquery-ui.css",
                      "~/Content/jquerytree.css"));

            //gridview
            bundles.Add(new StyleBundle("~/Content/list").Include(
                      "~/Content/list.css"));

            //layout
            //bundles.Add(new StyleBundle("~/Content/layout").Include(
            //                "~/Content/all.css",
            //                "~/Content/tab.css",
            //                "~/Content/validate.css"));
            bundles.Add(new StyleBundle("~/Content/layout").Include(
                        "~/Content/layout.css"));

            //login
            bundles.Add(new StyleBundle("~/Content/login").Include(
                        "~/Content/index_css.css"));

            //jquery-ui
            bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                        "~/Content/themes/base/jquery.ui.core.css",
                //"~/Content/themes/base/jquery.ui.resizable.css",
                //"~/Content/themes/base/jquery.ui.selectable.css",
                //"~/Content/themes/base/jquery.ui.accordion.css",
                        "~/Content/themes/base/jquery.ui.autocomplete.css",
                //"~/Content/themes/base/jquery.ui.button.css",
                //"~/Content/themes/base/jquery.ui.dialog.css",
                //"~/Content/themes/base/jquery.ui.slider.css",
                //"~/Content/themes/base/jquery.ui.tabs.css",
                        "~/Content/themes/base/jquery.ui.datepicker.css",
                //"~/Content/themes/base/jquery.ui.progressbar.css",
                        "~/Content/themes/base/jquery.ui.theme.css"));
            #endregion
        }

        private static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
        {
            if (ignoreList == null)
                throw new ArgumentNullException("ignoreList");
            ignoreList.Ignore("*.intellisense.js");
            ignoreList.Ignore("*-vsdoc.js");
            ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
            //ignoreList.Ignore("*.min.js", OptimizationMode.WhenDisabled);
            ignoreList.Ignore("*.min.css", OptimizationMode.WhenDisabled);
        }
    }
}